package com.ruoyi.web.controller.erpbase;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Outbounds;
import com.ruoyi.system.service.IOutboundsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 *  出库单Controller
 * 
 * @author he
 * @date 2025-09-22
 */
@Api(tags = "出库单接口")
@RestController
@RequestMapping("/system/outbounds")
public class OutboundsController extends BaseController
{
    @Autowired
    private IOutboundsService outboundsService;

    /**
     * 查询 出库单列表
     */
    @ApiOperation("查询出库单列表信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:list')")
    @GetMapping("/list")
    public TableDataInfo list(Outbounds outbounds)
    {
        startPage();
        List<Outbounds> list = outboundsService.selectOutboundsList(outbounds);
        return getDataTable(list);
    }

    /**
     * 导出 出库单列表
     */
    @ApiOperation("导出出库单信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:export')")
    @Log(title = " 出库单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Outbounds outbounds)
    {
        List<Outbounds> list = outboundsService.selectOutboundsList(outbounds);
        ExcelUtil<Outbounds> util = new ExcelUtil<Outbounds>(Outbounds.class);
        util.exportExcel(response, list, " 出库单数据");
    }

    /**
     * 获取 出库单详细信息
     */
    @ApiOperation("获取出库单详细信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(outboundsService.selectOutboundsById(id));
    }

    /**
     * 新增 出库单
     */
    @ApiOperation("新增出库单信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:add')")
    @Log(title = " 出库单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Outbounds outbounds)
    {
        return toAjax(outboundsService.insertOutbounds(outbounds));
    }

    /**
     * 修改 出库单
     */
    @ApiOperation("修改出库单信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:edit')")
    @Log(title = " 出库单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Outbounds outbounds)
    {
        return toAjax(outboundsService.updateOutbounds(outbounds));
    }

    /**
     * 删除 出库单
     */
    @ApiOperation("删除出库单信息")
    @PreAuthorize("@ss.hasPermi('system:outbounds:remove')")
    @Log(title = " 出库单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(outboundsService.deleteOutboundsByIds(ids));
    }
}
